package spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import spring.pojo.Animal;

public class SpringTest{

    public static void main(String[] args) {
        Animal animal;
        //Spring方式创建对象：
        //加载xml配置文件: applicationContext继承BeanFactory子类。所以可以用Bean工厂创建
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        //通过id获取对象
        animal = (Animal) applicationContext.getBean("Animal");
        animal.getDog().eat();

    }

}